package ZuoYe02_WuCanFangFa_0430;

//2:模拟QQ号升级.
//QQ号设计成类,有号码,昵称,在线时长等属性,
//还有等级属性,等级由在线时长累计得到,分为皇冠,太阳,星星,假设规则如下:
//在线一百天,获得一颗星星,三颗星星获得一个太阳,3个太阳获得一个皇冠
//(注意:晋级之后当前清零,比如有了三颗太阳,获得皇冠后,太阳为0).
//设计在线方法online,实现等级的进阶
public class QQnum {

	String num;
	String id;
	int onlineTime = 0;
	int star = 0;
	int sun = 0;
	int crown = 0;

	public void online() {

		while (true) {
			if (onlineTime % 10 == 0 && onlineTime != 0) {
				star++;
			}
			if (star == 3) {
				sun++;
				star = 0;
			}
			if (sun == 3) {
				crown++;
				sun = 0;
			}

			try {// 百度到的自加方法
				Thread.sleep(1 * 1000); // 设置暂停的时间 1 秒
				System.out.println("当前登录QQ号：" + num + "；昵称：" + id + "；在线时长：" + onlineTime + "天；");
				onlineTime++;
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			if (crown > 0) {
				System.out.println("当前等级：" + crown + "皇冠，" + sun + "太阳，" + star + "星。");
			} else if (sun > 0) {
				System.out.println("当前等级：" + sun + "太阳，" + star + "星。");
			} else if (star >= 0) {
				System.out.println("当前等级：" + star + "星。");
			}
//测试效果用	if (crown == 10) {
//				break;
//			}

		}

	}

	public static void main(String[] args) {
		QQnum qq = new QQnum();
		qq.num = "137251234";
		qq.id = "Mr.Unhappy";
		qq.online();

	}

}
